<html>
<head><meta charset="utf-8"><title>building rustc and missing CXXFLAGS · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html">building rustc and missing CXXFLAGS</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203996115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/203996115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#203996115">(Jul 15 2020 at 18:44)</a>:</h4>
<p>So, in the continuing trend of "doing everything on hard mode" for me: I'm trying to build rustc with our canonical C++ compilers (but still the bundled LLVM) statically so I can get it running without gross hacks on our build machines. The wrinkle is that our libc++ was built with <code>-D_GLIBCXX_USE_CXX11_ABI=0</code> and when I try to do that in config.toml, the resulting <code>llvm-config</code> doesn't seem to know about that flag (or any of the other nonsense I dumped in <code>cflags</code> and <code>cxxflags</code> in config.toml). Has anyone seen this kind of issue before? Any pointers on how to debug this phase of the build process?</p>



<a name="204008461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204008461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204008461">(Jul 15 2020 at 20:26)</a>:</h4>
<p>Related: I see <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_llvm/build.rs#L281">https://github.com/rust-lang/rust/blob/master/src/librustc_llvm/build.rs#L281</a> which seems to indicate that statically linking rustc against libc++  isn't supported, but I can't  find a reason. Does  anyone  know why that line is there?</p>



<a name="204091096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Benjamin Brittain <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091096">(Jul 16 2020 at 14:30)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> or <span class="user-mention" data-user-id="116011">@Steve Klabnik</span> might have the history on this :)</p>



<a name="204091172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steve Klabnik <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091172">(Jul 16 2020 at 14:30)</a>:</h4>
<p>hmmm</p>



<a name="204091261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steve Klabnik <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091261">(Jul 16 2020 at 14:31)</a>:</h4>
<p>i do not know</p>



<a name="204091349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Benjamin Brittain <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091349">(Jul 16 2020 at 14:31)</a>:</h4>
<p>any thoughts on who might know?</p>



<a name="204091458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steve Klabnik <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091458">(Jul 16 2020 at 14:32)</a>:</h4>
<p>my go-to for build stuff is alex</p>



<a name="204091483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091483">(Jul 16 2020 at 14:32)</a>:</h4>
<p>I assume I should fire up a VM or something and try to make it work? I suspect I'll trip on the "missing CXXFLAGS" nonsense again, but this is basically a blocker for me landing properly-supportable rustc at work.</p>



<a name="204091485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Benjamin Brittain <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091485">(Jul 16 2020 at 14:32)</a>:</h4>
<p>yeah, I was worried you'd say that :P</p>



<a name="204091606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steve Klabnik <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091606">(Jul 16 2020 at 14:33)</a>:</h4>
<p><span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="204091687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204091687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Benjamin Brittain <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204091687">(Jul 16 2020 at 14:33)</a>:</h4>
<p>We can email Alex I guess <span class="user-mention" data-user-id="316805">@durin42</span></p>



<a name="204093507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204093507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204093507">(Jul 16 2020 at 14:46)</a>:</h4>
<p>thanks <span class="user-mention" data-user-id="116011">@Steve Klabnik</span> , hopefully I get somewhere useful soon :)</p>



<a name="204099379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204099379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204099379">(Jul 16 2020 at 15:26)</a>:</h4>
<p><span class="user-mention" data-user-id="316805">@durin42</span> sorry to ask potentially dumb questions, but by "canonical C++ compiler", do you mean the Canonical that makes Ubuntu?</p>



<a name="204099506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204099506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204099506">(Jul 16 2020 at 15:26)</a>:</h4>
<p>I'm basically trying to find out what someone would need to do to reproduce your problem locally</p>



<a name="204099812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204099812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204099812">(Jul 16 2020 at 15:29)</a>:</h4>
<p>No, we've got a C++ toolchain team that maintains a clang/clang++ build.</p>



<a name="204099841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204099841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204099841">(Jul 16 2020 at 15:29)</a>:</h4>
<p>I'm working on a dockerfile now to build an environment to reproduce this.</p>



<a name="204099895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204099895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204099895">(Jul 16 2020 at 15:29)</a>:</h4>
<p>okay great</p>



<a name="204107632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204107632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204107632">(Jul 16 2020 at 16:23)</a>:</h4>
<p>Alrighty, I've got a minimal reproduction recipe that at least shows a surprising result. It's not the _same_ result, but it's surprising in a way that seems related.</p>
<p><a href="https://gist.github.com/durin42/31338b84f97f21b371e2150bedd144e6">https://gist.github.com/durin42/31338b84f97f21b371e2150bedd144e6</a></p>
<p>I built rust using that setup, and AFAICT I've asked pretty specifically for a static dep on libc++, but then I get this at the end:</p>
<div class="codehilite"><pre><span></span><code>$ ldd build/x86_64-unknown-linux-gnu/stage2/bin/rustc  | grep c++
    libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f084b77d000)
</code></pre></div>



<a name="204260519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204260519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204260519">(Jul 17 2020 at 21:19)</a>:</h4>
<p>Okay, I got past most of the issues and I've now got that gist (updated, same URL) to the same place I got with our internal compilers: it looks for all the world like <code>llvm-config --cxxflags</code> is omitting important flags. Is that believable? Am I configuring rustbuild correctly to be using the non-C++11 ABI and libc++ in llvm?</p>



<a name="204434522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20rustc%20and%20missing%20CXXFLAGS/near/204434522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> durin42 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20rustc.20and.20missing.20CXXFLAGS.html#204434522">(Jul 20 2020 at 15:10)</a>:</h4>
<p>It looks like user-specified CFLAGS and CXXFLAGS, such as those we put in config.toml are <em>not</em> expected to come back from <code>llvm-config --cflags</code> etc, so we should take the configured CFLAGS and CXXFLAGS from <code>config.toml</code> and thread them down into the Rust crates that build some C++ and try to link against llvm. Does that sound reasonable?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>